package com.lims.dao.common.impl;

import java.util.List;


import com.lims.dao.base.BaseDAOImpl;
import com.lims.dao.common.IDepartmentDAO;
import com.lims.po.common.Department;

public class DepartmentDAOImpl extends BaseDAOImpl<Department> implements IDepartmentDAO {
	private static final String className=DepartmentDAOImpl.class.toString();
	public List<Department> selectAll(){
		String hql="from Department order by pid ";
		return super.ExecuteQuery(hql, className+"-->selectAll()");
	}
	public boolean saveDepartment(Department department){
		return super.saveObject(department, className+"-->saveDepartment(Department Department)")>0?true:false;
	}
	public boolean updateDepartment(Department department){
		return super.updateObject(department, className+"-->updateDepartment(Department Department)");
	}
	public boolean deleteDepartment(Department department){
		return super.deleteObject(department, className+"-->deleteDepartment(Department Department)");
	}
	public boolean deleteDepartmentById(int pid){
		String hql="delete from Department where pid="+pid;
		return super.ExecuteNonQuery(hql, className+"-->deleteDepartmentById(int pid)");
	}
	
	public Department selectDepartmentById(int pid) {
		return super.selectById(pid, className+"-->selectDepartmentById(int pid)");
	}
	public boolean selectDepartmentBySampleTitle(String department) {
		String hql="from Department where DepartmentName='"+department+"'";
		return super.ExecuteQuery(hql, className+"-->selectDepartmentByDepartmentName(String DepartmentName)").size()==0?false:true;
	
	}
	public List<Department> selectAllByProjectId(int projectId) {
		String hql="from Department where pid not in(select department.pid from Task where project.pid="+projectId+") order by pid ";
		return super.ExecuteQuery(hql, className+"-->selectAllByProjectId(int projectId)");
	}
}
